package zy06;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;

public class zy10 {
    public static void main(String[] args) {
        ArrayList<String> poker = new ArrayList<>();
        String[] colors = {"♥", "♣", "♦", "♠"};
        String[] numbers = {"2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"};

        poker.add("大王");
        poker.add("小王");
        poker.addAll(Arrays.stream(numbers)
                .flatMap(number -> Arrays.stream(colors).map(color -> color + number))
                .collect(Collectors.toList()));

        System.out.println(poker);

        Map<Integer, String> map = IntStream.range(0, poker.size())
                .boxed()
                .collect(Collectors.toMap(i -> i, poker::get));

        System.out.println(map);

        Random r = new Random();
        Set<Integer> index = new HashSet<>();
        while (index.size() < 9) {
            index.add(r.nextInt(54));
        }

        System.out.println(index);

        int[] userP = index.stream().mapToInt(Integer::intValue).toArray();
        Arrays.sort(userP);

        ist<String> lookPoker = Arrays.stream(userP)
                .mapToObj(map::get)
                .collect(Collectors.toList());

        System.out.println(lookPoker);
    }
}
